package ctrlLayer;

import java.util.ArrayList;

import dbLayer.QuestionDb;
import modelLayer.Question;

public class QuestionCtrl {
	
	private ArrayList<Question> questions;
	private Question q;
	private QuestionDb qDb;
	
	public QuestionCtrl(){
		qDb = new QuestionDb();
		
	}
	
	public void createQuestion(String question, String answer, int tNo) throws Exception{
		q = new Question();
		q.setQuestion(question);
		q.setAnswer(answer);
		qDb.insertQuestion(q, tNo);
	}
	
	public void updateQuestion(Question q) throws Exception{
		qDb.updateQuestion(q);
	}
	
	public void deleteQuestion(Question q) throws Exception{
		qDb.deleteQuestion(q);
	}
	
	public Question findQuestion(int qNo){
		return qDb.findQuestion(qNo);
	}
	
	public ArrayList<Question> listAllQuestions(){
		return qDb.findAllQuestions();
	}
	
	public ArrayList<Question> listBySubject(int sNo){
		return qDb.findBySubject(sNo);
	}
	
	public ArrayList<Question> listByLevel(int lNo){
		return qDb.findByLevel(lNo);
	}

	public ArrayList<Question> listByTopic(int tNo){
		return qDb.findByTopic(tNo);
	}
}
